//
//  TiXianApplyVC.m
//  NtoccShipper
//
//  Created by zcj on 2021/1/28.
//  Copyright © 2021 zhuchongjin. All rights reserved.
//

#import "TiXianApplyVC.h"

@interface TiXianApplyVC ()
@property (nonatomic,strong) CJLabel *labBankNum;
@property (nonatomic,strong) CJTextField *fieldTiXianMoney;

@end

@implementation TiXianApplyVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setTitleName:@"提现申请"];
    [self setBackLeftButton:@""];
    
    [self createTopView];
    [self setFieldLimt];
    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self loadData];
}
- (void)createTopView{
    //    WS(ws);
    CGRect rcFrame = CGRectMake(0, kTopHeight, [[UIScreen mainScreen] bounds].size.width, 0);
    FlexFrameView  *header = [[FlexFrameView alloc] initWithFlex:@"TiXianApplyView" Frame:rcFrame Owner:self];
    header.flexibleHeight = YES;


    
    self.fieldTiXianMoney.placeholder = CJStringWithFormat(@"最高可提现¥%@元",@(self.maxTiXianMoney).cj_money_description);  //@"1,988.00";
    
    [header layoutIfNeeded];
    [self.view addSubview:header];
}

- (void)setFieldLimt{
    
    self.fieldTiXianMoney.maxLength = 10;
    self.fieldTiXianMoney.textFieldType = CJTextFieldStringTypeMoneyValue;
    
}


- (void)loadData{
    
    
    NSString *strURL = CJStringWithFormat(@"%@/ntocc-tms-api/mybankMerchant/%@",CJBaseUrl,[CJControl getPartyCode]);
    NSDictionary *dicPar = [[NSDictionary alloc]init];
    
    WS(ws);
    [[HDNetworking sharedHDNetworking] GET:strURL parameters:dicPar success:^(id  _Nonnull responseObject) {
        
        NSDictionary *dic = (NSDictionary *)responseObject;
        NSDictionary *dicCard = dic[@"card"];
        ws.labBankNum.text = [CJControl getThreeUnaryValueStr:dicCard[@"bankCardNo"]];
    //    self.fieldTiXianMoney.text = @"¥1,988.00元";
//        ws.relateOrderNo = [CJControl getThreeUnaryValueStr:dic[@"orderNo"]];
    } failure:^(NSError * _Nonnull error) {
        DLog(@"++++++++%@",error);
        
    }];

}

- (void)touchSureTiXianAction{
    
    if ([self.fieldTiXianMoney.text floatValue] > self.maxTiXianMoney) {
        
        [CJAlert showStringDismissWithDelay:CJStringWithFormat(@"最高可提现¥%@元",@(self.maxTiXianMoney).cj_money_description)];
    }else{
        
        NSString *strUrl = CJStringWithFormat(@"%@/ntocc-tms-api/mybankCashDepositRefund/createRefund",CJBaseUrl);
        
        NSDictionary *dicPra = @{
            @"refundAmount":[CJControl getThreeUnaryValueStr:self.fieldTiXianMoney.text],
            @"relateOrderNo":self.relateOrderNo
        };
        WS(ws);
        [[HDNetworking sharedHDNetworking] POST:strUrl parameters:dicPra success:^(id  _Nonnull responseObject) {

            DLog(@"++++++++%@",responseObject);
            [ws pop];

        } failure:^(NSError * _Nonnull error) {
            DLog(@"++++++++%@",error);

        }];
        
        
    }
    
    
}


@end
